function Model(){
	this.geometry = null;
	this.geometry_meterial=null;
	this.mesh=null;
	this.positon=null;
	this.rotation=null;
	this.scale=null;	
	this.group=null;
	
	this.url=null;
	
	this.castShadow=false;
	this.receiveShadow=false;
	this.transparent = false;
	//init
	this.position={x:0,y:0,z:0};
	this.rotation={x:0,y:0,z:0};
	this.scale={ratio:1};
}
Model.prototype={
		constructor : Model,
		loadToGroup:function(url,group){
			this.group=group;
			this.url=url;
			var loader = new THREE.JSONLoader();
			var myModel=this;
			loader.load({model: this.url, callback:function(geometry){
																							myModel.loadSuccess(geometry); 
																						}
									});
		},
		
		loadSuccess: function (geometry ) {
			this.geometry=geometry;
			if(this.geometry_meterial!=null){
				this.geometry.materials[ 0 ]=this.geometry_meterial;
			}
			var meterial = new THREE.MeshFaceMaterial();
			this.geometry.materials[ 0 ].transparent = this.transparent;
			this.mesh = new THREE.Mesh( this.geometry, meterial);
			this.mesh.castShadow = this.castShadow;
			this.mesh.receiveShadow  = this.receiveShadow;
			
			//put the mesh to ground (mesh include"model+meterial+vector")
			this.group.add(this.mesh);   
			this.update();
		},
		update: function(){
			if(this.mesh!=null){
				this.mesh.position.x = this.position.x;
				this.mesh.position.y = this.position.y;
				this.mesh.position.z = this.position.z;
				this.mesh.rotation.x = this.rotation.x;
				this.mesh.rotation.y = this.rotation.y;
				this.mesh.rotation.z = this.rotation.z;
				this.mesh.scale.x = this.mesh.scale.y = this.mesh.scale.z =this.scale.ratio;
			}
		}
};

function ModelManager(){
	this.modelList=new Array();
}
ModelManager.prototype={
		constructor: ModelManager,
		add:function(model){
			this.modelList.push(model);
			
		},
		update:function(){
			for(var i=0;i<this.modelList.length;i++){
				this.modelList[i].update();
			}
		}
};